package cn.wolfcode.edu.service.impl;

import cn.wolfcode.edu.domain.Department;
import cn.wolfcode.edu.mapper.DepartmentMapper;
import cn.wolfcode.edu.query.QueryObject;
import cn.wolfcode.edu.service.IDepartmentService;
import cn.wolfcode.edu.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by abb on 2018-07-08.
 */
@Service
public class DepartmentServiceImpl implements IDepartmentService{
    @Autowired
    DepartmentMapper departmentMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {
        departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(Department entity) {
        departmentMapper.insert(entity);
    }

    @Override
    public Department selectByPrimaryKey(Long id) {
        return departmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(Department entity) {
        departmentMapper.updateByPrimaryKey(entity);
    }

    @Override
    public PageResult query(QueryObject qo) {
        int total = departmentMapper.queryForCount(qo);
        List<Department> rows = departmentMapper.queryForList(qo);
        return new PageResult(total,rows) ;
    }

    @Override
    public void close(Long id) {
        departmentMapper.close(id);
    }
}
